package cn.yanhu.kuwanapp.utils.helper

import android.content.Context
import cn.woochen.comlib.util.UserPref
import cn.yanhu.kuwanapp.http.UrlConstainer
import cn.yanhu.kuwanapp.utils.constans.Constants
import cn.yanhu.kuwanapp.utils.ext.logcom
import com.qiyukf.unicorn.api.ConsultSource
import com.qiyukf.unicorn.api.Unicorn
import com.qiyukf.unicorn.api.YSFUserInfo
import java.lang.String

/**
 *类描述：客服帮助类
 *@author woochen
 *@time 2021/8/6 14:37
 */
object ServiceHelper {

    private var mUserId by UserPref(Constants.USER_ID, "")


    /**
     * 打开客服
     */
    fun open(context: Context){
        try {
            Unicorn.setUserInfo(null)
            val userInfoA = YSFUserInfo()
            userInfoA.userId = mUserId
            userInfoA.data = ""
            Unicorn.setUserInfo(userInfoA)
            val source = ConsultSource(Constants.QIYU_SOURCEURL, Constants.QIYU_SOURCE_TITLE, Constants.QIYU_CUSTOM)
            Unicorn.openServiceActivity(context, Constants.QIYU_SOURCE_TITLE, source)
        } catch (e: Exception) {
            if (UrlConstainer.SHOW_LOG){
                e.printStackTrace()
            }
        }
    }
}